package com.yboot.starter.tenant.core.aspect;

import com.yboot.starter.tenant.core.annotation.TenantIgnore;
import com.yboot.starter.tenant.core.context.TenantContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Aspect
@Slf4j
public class TenantIgnoreAspect {

    @Around("@annotation(tenantIgnore)")
    public Object around(ProceedingJoinPoint joinPoint, TenantIgnore tenantIgnore) throws Throwable {
        try {
            TenantContextHolder.push(true);
            // 执行逻辑
            return joinPoint.proceed();
        } finally {
            TenantContextHolder.poll();
        }
    }

}